package com.xiaofei.mapper;

import com.xiaofei.pojo.emp;
import com.xiaofei.pojo.empExpr;
import com.xiaofei.pojo.empLogin;
import com.xiaofei.pojo.empPage;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmpMapper {
    List<emp> page(empPage emp);

    void deleteByIds(List<Integer> ids);

    void deleteExprBathch(List<Integer> ids);

    //添加用户信息
    @Options(useGeneratedKeys = true, keyProperty = "id")//开启回填id，并赋值
    @Insert("insert into java_demo_tails.emp values (null,#{username},#{name},#{password},#{gender},#{image}," +
            "#{job},#{salary},#{entryDate},#{deptId},#{createTime},#{updateTime},#{phone})")
    void addEmp(emp e);


    //根据id查询用户信息
//    @Select("select *from java_demo_tails.emp e left join java_demo_tails.expr ex on e.id = ex.emp_id where e.id = #{id}")
    @Select("select *from java_demo_tails.emp where id = #{id}")
    emp getById(Integer id);

    //修改
    @Select("select *from java_demo_tails.expr where emp_id = #{id}")
    List<empExpr> getExprById(Integer id);

    //修改emp信息
    void updateEmp(emp e);

    @Delete("delete from java_demo_tails.expr where emp_id = #{id}")
    void deleteExpr(int id);

    //    List<empExpr> getExprById(Integer id);
    //修改empExpr信息
    void addExpr(List<empExpr> exprList);

    @Select("select *from java_demo_tails.emp where user_name = #{username} and password = #{password}")
    empLogin login(emp e);
}












